package com.ecmcloud.flow.resource;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ecmcloud.common.dto.IndexPageStatistics;
import com.ecmcloud.common.dto.Result;
import com.ecmcloud.common.dto.VariableQueryParamDto;
import com.ecmcloud.flow.service.ProcessInstanceService;

/**
 * 任务控制器
 */
@RestController
@RequestMapping("process-instance")
public class ProcessInstanceResource {

    @Autowired
    private ProcessInstanceService processInstanceService;
    
    /**
     * 查询统计数量
     * @param userId
     * @return
     */
    @GetMapping("querySimpleData")
    public Result<IndexPageStatistics> querySimpleData(String userId){
        IndexPageStatistics indexPageStatistics = processInstanceService.querySimpleData(userId);
        return Result.success(indexPageStatistics);
    }

    /**
     * 查询变量
     * @param paramDto
     * @return
     */
    @PostMapping("queryVariables")
    public Result<Map<String, Object>> queryVariables(@RequestBody VariableQueryParamDto paramDto) {
        Map<String, Object> variables = processInstanceService.queryVariables(paramDto);
        return Result.success(variables);
    }

}
